package jsyf.oa.dao.business;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jsyf.oa.entity.business.TrustTrialAttachEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Maqiuqiu on 2018/6/12.
 */
@Repository
public class TrustTrialAttachDao extends BaseDao {

    public TrustTrialAttachDao() {
        super.iBaseEntity = new TrustTrialAttachEntity();
    }

    public List<TrustTrialAttachEntity> getEntityListByCondition(String condition, Object[] params) {
        List<JSONObject> jsonList = getJSONListByCondition(condition, params);
        List<TrustTrialAttachEntity> entityList = new ArrayList<>();
        for (int i = 0; i < jsonList.size(); i++) {
            TrustTrialAttachEntity entity = (TrustTrialAttachEntity) convertJson2Entity(jsonList.get(i));
            entityList.add(entity);
        }
        return entityList;
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, TrustTrialAttachEntity.class);
    }
}
